package com.vay.de.dang.online.view;

import android.content.Context;
import android.widget.TextView;

import com.vay.de.dang.online.R;

public class DialogConfirm extends DialogBase {

    private TextView titleTv;
    private TextView contentTv;
    private TextView hintTv;
    private DialogCallback mCallback;

    public DialogConfirm(Context context) {
        super(context);
        setContentView(R.layout.dialog_confirm);
        autoWidth(0.88f);

        titleTv = findViewById(R.id.title);
        contentTv = findViewById(R.id.content);
        hintTv = findViewById(R.id.hint);

        findViewById(R.id.bnt_no).setOnClickListener(v -> {
            dismiss();
        });

        findViewById(R.id.bnt_yes).setOnClickListener(v -> {
            if (mCallback != null) mCallback.onConfirm();
            dismiss();
        });
    }

    public DialogConfirm setTitleText(int restId) {
        titleTv.setText(restId);
        return this;
    }

    public DialogConfirm setContentText(String content) {
        contentTv.setText(content);
        return this;
    }

    public DialogConfirm setHintText(int restId) {
        hintTv.setText(restId);
        return this;
    }

    public void showConfirm(DialogCallback callback) {
        mCallback = callback;
        show();
    }
}
